class Student {
  name: string;
  chinese: number;
  math: number;
  english: number;
  constructor(name: string, chinese: number, math: number, english: number) {
    this.name = name;
    this.chinese = chinese;
    this.english = english;
    this.math = math;
  }
  fun(): void {
    let avg: number = (this.chinese + this.english + this.math) / 3;
    let max: number = Math.max(this.chinese, this.english, this.math);
    let min: number = Math.min(this.chinese, this.english, this.math);
    console.log(
      `${this.name}的平均分是${avg.toFixed(2)}，最高分是${max}，最低分是${min}`
    );
  }
}

class StuClass {
  students: Student[];
  constructor(students: Student[]) {
    this.students = students;
  }
  fun1() {
    let chineseMax: number = 0;
    let chineseMin: number = Infinity;
    let chineseSum: number = 0;

    this.students.forEach((item: Student) => {
      if (chineseMax < item.chinese) {
        chineseMax = item.chinese;
      }
      if (chineseMin > item.chinese) {
        chineseMin = item.chinese;
      }
      chineseSum += item.chinese;
    });
    let chineseAvg: number = chineseSum / this.students.length;
    console.log(
      `本班语文成绩最高分是${chineseMax}， 最低分是${chineseMin}, 平均分是${chineseAvg.toFixed(
        2
      )}`
    );
  }
}

let stu: Student = new Student("张三", 80, 90, 95);
stu.fun();
let stu1: Student = new Student("李四", 67, 75, 68);
stu1.fun();
let cls1: StuClass = new StuClass([stu, stu1]);
cls1.fun1();
